package com.shg.admin.config;

import com.alibaba.druid.pool.DruidDataSource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.sql.SQLException;

/**
 * @DESCRIPTION:
 * @USER: shg
 * @DATE: 2023/11/29 21:33
 */
@Slf4j
// @Configuration
public class MyDataSourceConfig {
    
    @Bean
    @ConfigurationProperties(value = "spring.datasource")
    public DruidDataSource druidDataSource() throws SQLException {
        DruidDataSource druidDataSource = new DruidDataSource();
        // 打开Druid的监控统计功能
        druidDataSource.setFilters("stat");
        // 配置防御SQL注入攻击
        druidDataSource.setFilters("wall");
        return druidDataSource;
    }
}
